package com.leng.controller;


import com.leng.entity.Menu;
import com.leng.response.Result;
import com.leng.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author leng
 * @since 2022-08-21
 */
@Api(tags = "MenuController", value = "MenuController")
@RestController
@RequestMapping("/menu")
@CrossOrigin
public class MenuController {
    @Autowired
    private MenuService menuService;

    /*
     * 加载菜单树
     * */
    @ApiOperation(value = "加载菜单树", notes = "获取所有菜单树，以及展开选项")
    @GetMapping("/tree")
    public Result tree() {
        //查找菜单树
        List<Menu> menuTree=menuService.findMenuTree();
        //获取展开的菜单树
        return Result.ok().data("menuTree",menuTree);
    }
}

